package sbpme.designer.command;

import org.eclipse.gef.commands.Command;

import sbpme.designer.model.Transition;

public class TransitionDeleteCommand extends Command {

	private final Transition transition;

	public TransitionDeleteCommand(Transition transition) {
		if (transition == null) {
			throw new IllegalArgumentException();
		}
		setLabel("transition deletion");
		this.transition = transition;
	}

	public void execute() {
		transition.getSource().removeSourceTransition(transition);
		transition.getTarget().removeTargetTransition(transition);
	}

	public void undo() {
		transition.getSource().addSourceTransition(transition);
		transition.getTarget().addTargetTransition(transition);
	}
}
